/*
 * SPDX-FileCopyrightText: 2010-2022 Espressif Systems (Shanghai) CO LTD
 *
 * SPDX-License-Identifier: CC0-1.0
 */

#include <stdio.h>
#include <inttypes.h>
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_chip_info.h"
#include "esp_flash.h"

#include "esp_efuse.h"
#include "esp_efuse_table.h"
#include "esp_log.h"

#include "IO_DEF.h"
#include "CAN.h"
#include "MCP2515.h"
#include "SOFT_SPI.h"

twai_message_t msg;
uint8_t RES=0;

void app_main(void)
{
    msg.identifier=0x55;
    SOFT_SPI_Init();
    TWAI_CAN_Init(CAN_500K);
    // xTaskCreatePinnedToCore(TWAI_CAN_RECOVERY_TASK, "CAN_RECOVERY", 4096, NULL, 8, NULL, tskNO_AFFINITY);
    while(1)
    {
        // printf("Hello world!\n");
        // vTaskDelay(1000);
        // twai_transmit(&msg,10);
        // vTaskDelay(1000);
        
        SOFT_W_CS_L();
        vTaskDelay(10);
        SOFT_SPI_ReadWriteByte(0x03);
        SOFT_SPI_ReadWriteByte(0x1F);
        RES=SOFT_SPI_ReadWriteByte(0xFF);
        vTaskDelay(10);
        SOFT_W_CS_H();

        printf("RES:%02X\n",RES);
        vTaskDelay(100);
    }
    
}






